/************************************************************************
                        CourseLectTimeSemeter.h.cpp - Copyright asaf

**************************************************************************/

#include "CourseLectTimeSemeter.h"
// Constructors/Destructors
CourseLectTimeSemeter::~CourseLectTimeSemeter ( ) { }

CourseLectTimeSemeter::CourseLectTimeSemeter (Course &c,Person &p,int maxatt):m_CourseRef(c),m_LecturerRef(p),maxAttendants(maxatt),currentAttendants(0){;}

CourseLectTimeSemeter::CourseLectTimeSemeter(const CourseLectTimeSemeter &rhs):m_CourseRef(rhs.m_CourseRef),m_LecturerRef(rhs.m_LecturerRef),m_time(rhs.m_time),maxAttendants(rhs.getMaxAtt()),currentAttendants(rhs.getCurrentAtt()){;}
// Methods

//checks if lecture is full
bool CourseLectTimeSemeter::isFull(){if(currentAttendants<maxAttendants)return false;return true;}

//++ on num of Attendants for this lecture
void CourseLectTimeSemeter::addAttendant(){if(currentAttendants<maxAttendants)currentAttendants++;}
//-- on num of Attendants for this lecture
void CourseLectTimeSemeter::subAttendant(){if(currentAttendants>0)currentAttendants--;}
//return the num of free palces for this lecture
int CourseLectTimeSemeter::freePlaces(){return maxAttendants-currentAttendants;}


bool CourseLectTimeSemeter::operator==(const CourseLectTimeSemeter& rhs)
{
	return ((m_CourseRef==rhs.getCourseRef())&&
		((m_LecturerRef==rhs.getLecturerRef())||((m_LecturerRef).getID()=="DEFAULT"))&&
		(m_time.isAcademicTimeOverlapping(rhs.m_time)||
		(rhs.m_time.isEmpty())));
}

bool CourseLectTimeSemeter::operator==(const AcademicTime& rhs)
{
	return (((m_time.getStartingHour()==rhs.getStartingHour())||(rhs.getStartingHour()==0))&&
			((m_time.getEndingHour()==rhs.getEndingHour())||(rhs.getEndingHour()==0))&&
			((m_time.getWeekday()==rhs.getWeekday())||(rhs.getWeekday()==0))&&
			((m_time.getSemester()==rhs.getSemester())||(rhs.getSemester()==0)));
}

bool CourseLectTimeSemeter::operator==(const Course& rhs)
{
	return (m_CourseRef==rhs);
}


Course & CourseLectTimeSemeter::getCourseRef()const{return m_CourseRef;}
Person & CourseLectTimeSemeter::getLecturerRef()const{return m_LecturerRef;}
Course & CourseLectTimeSemeter::getCourseRef(){return m_CourseRef;}
Person & CourseLectTimeSemeter::getLecturerRef(){return m_LecturerRef;}
string CourseLectTimeSemeter::getCourseName(){return m_CourseRef.getCourseName();}
AcademicTime & CourseLectTimeSemeter::getTime ( ){return m_time;}
int CourseLectTimeSemeter::getMaxAtt()const{return maxAttendants;}
int CourseLectTimeSemeter::getCurrentAtt()const{return currentAttendants;}